/**
 * 
 */
package com.cp16.tss.validation;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

import com.cp16.tss.common.Constants;

/**
 * @author ADMIN
 *
 */
public class CommonValidation {
	// Method check a field is username or not
		public static boolean isUsername(String Value) {
			Pattern pattern = Pattern.compile(Constants.USERNAME_REG);
			Matcher matcher = pattern.matcher(Value);
			if (!matcher.find()) {
				return false;
			} else {
				return true;
			}
		}

		// Check a string is numberic
		public static boolean isNummeric(String value) {
			Pattern pattern = Pattern.compile(Constants.NUMMERIC_REG);
			Matcher matcher = pattern.matcher(value);
			if (!matcher.find()) {
				return false;
			} else {
				return true;
			}
		}

		// Validate email input
		public static boolean checkEmail(String value) {
			Pattern pattern = Pattern.compile(Constants.EMAIL_REG);
			Matcher matcher = pattern.matcher(value);
			if (!matcher.find()) {
				return false;
			} else {
				return true;
			}
		}

		// Validate phone number
		public static boolean checkPhoneNumber(String value) {
			Pattern pattern = Pattern.compile(Constants.PHONE_REG);
			Matcher matcher = pattern.matcher(value);
			if (!matcher.find()) {
				return false;
			} else {
				return true;
			}
		}
}
